<?php

namespace App\Jobs\Train;

use App\Models\Train\TrainSeat\Repositories\Interfaces\TrainSeatRepositoryInterface;
use App\Trip\Train\Seat\Seats;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcessAddTrainSeat implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private Seats $trainSeat;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(Seats $trainSeat)
    {
        $this->trainSeat = $trainSeat;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $trainSeatRepo = app(TrainSeatRepositoryInterface::class);
        $trainSeatRepo->addTrainSeat($this->trainSeat->toAddData());
    }
}
